import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class arraytoList {
	public static void main(String[] args) {

		String[] rndString = new String[10000];
		
		for (int i = 0; i < rndString.length; i++) {
			rndString[i] = randString(4);
		}
		
		for (String str : rndString) {
			// System.out.println(str);
		}
		
		long t1, t2, t3, t4;
		t1 = System.currentTimeMillis();
		
		ArrayList<String> al = new ArrayList<String>
		(Arrays.asList(rndString));
		
		t2 = System.currentTimeMillis();
		
		System.out.println("Time taken by arraylist is " + (t2 - t1));

		t3 = System.currentTimeMillis();
		
		LinkedList ll = new LinkedList(Arrays.asList(rndString));
		
		t4 = System.currentTimeMillis();
		
		System.out.println("Time taken by linkedlist is " + (t4 - t3));

		al.add(9999, "pppp");

		 System.out.println(al);
	}

	public static String randString(int len) {
		String s = new String();
		for (int i = 0; i < len; i++) {
			s = "" + rndChar() + s;

		}
		return s;
	}

	public static char rndChar() {
		int rnd = (int) (Math.random() * 52);
		char base = (rnd < 26) ? 'A' : 'a';
		return (char) (base + rnd % 26);
	}
}
